﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UM_SERVER.Packet.InPacket;
using UM_SERVER.Packet.InPacket.UpdateUserInfo;
using UM_SERVER.ProcessModel;

namespace UM_SERVER.Packet
{
    class TalkMessagePacketListener : IPacketListener
    {

        #region IPacketListener 成员

        public bool Accpet(InPackage pck)
        {
            return pck.GetProtocol() == Protocol.NetworkProtocol.TALK_MESSAGE;
        }

        public void PackageArrived(InPackage pck)
        {
            Session.Session session = Globle.sessionManager.GetSessionByCode(pck.GetSessionCode()) as Session.Session;
            //能够得到当前用户会话，并且该会话可用
            if (session != null && !session.GetExprid())
            {
              switch ((pck as TalkMessageInPackage).Command)
              {
                  //打洞请求
                  case Protocol.TALK_IN_NetworkCommand.DIG_A_HOLE:
                      ServerProcessModel.ProcessUserDigHole(new UM_SERVER.Packet.InPacket.TalkMessage.Hole.DigHolePacket(pck as TalkMessageInPackage));
                      break;
                  //打洞回馈
                  case Protocol.TALK_IN_NetworkCommand.ACK_HOLE:
                      ServerProcessModel.ProcessAckDigHole(new UM_SERVER.Packet.InPacket.TalkMessage.Hole.Ack_DigHolePacket(pck as TalkMessageInPackage));
                      break;
              }
          }
        }
        #endregion
    }
}
